#include<iostream>

using namespace std;

const int mod=1e9+7;
int n,max_num=0,min_num=5000;
long long ans,c,temp,num[5001];

int C (int a,int r){
    if (r==1) return a;
    return a*(a-1)/2 % mod;
}


int main(){
    scanf("%d",&n);
    for (int i = 0; i < n; i++) {
        scanf("%lld",&temp);
        if(!num[temp]){
            max_num = max_num>temp? max_num : temp;
            min_num = min_num<temp? min_num : temp;
        }
        num[temp]++;
        }

    for (int i = min_num+1; i <= max_num; i++)
    {
        if (num[i]==1||num[i]==0) continue;
        c = C(num[i],2);
        for (int j = min_num; j <= i/2; j++)
        {
            if(num[j]&&num[i-j]){
                if(j<<1 == i && num[j]>=2) 
                ans = ans + c * C(num[j],2) % mod;
                else 
                ans = ans + c *( num[j] * num[i-j] % mod) % mod;
                ans %= mod;
            }
        }
    }
    
    printf("%lld\n",ans%mod);
    
}